﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
public partial class DrawPloygons : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        int width = 300, hight = 250;
        Point p1 = new Point(30, 30); PointF pf1 = new PointF(130.0f, 30.0f);
        Point p2 = new Point(60, 10); PointF pf2 = new PointF(160.0f, 10.0f);
        Point p3 = new Point(100, 60); PointF pf3 = new PointF(200.0f, 60.0f);
        Point p4 = new Point(60, 120); PointF pf4 = new PointF(160.0f, 120.0f);

        Point[] points = { p1, p2, p3, p4 };
        PointF[] pointFs = { pf1, pf2, pf3, pf4 };

        using(Bitmap bmp=new Bitmap(width,hight))
        {
            using(Graphics g=Graphics.FromImage(bmp))
            {
                g.Clear(Color.White);
                using (Pen pen1=new Pen(Color.Blue,5))
                {
                    g.DrawPolygon(pen1, points);
                    g.DrawPolygon(pen1, pointFs);
                    bmp.Save(this.Server.MapPath("temp\\"+"Polygons.Png"),
                        System.Drawing.Imaging.ImageFormat.Png);
                    Image1.ImageUrl = "temp\\Polygons.Png";
                }
            }
        }
    }
}